<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
namespace core;
defined('BY_JYA') or exit('error');
class syskefu{
		public function jinyunrobot($msg=''){
			$setting=core_setting('site');
			$apikey=$setting['jyrobotkey'];
			$url='http://ai.jinyunweb.com/api/robot.php?apikey='.$apikey.'&question='.$msg;
			$res=file_get_contents($url);
			$res=json_decode($res,true);
			if(is_array($res) && $res['type']=='success'){
				return $res['message'];
			}else{
				return 0;
			}
		}
		public function getchatid($userid=0,$kefuid=0){
			global $_AR;
			if(empty($userid) && empty($kefuid) && $_SESSION['uniacid']){
				//exi('缺少必要参数','error');
			}
			$params['uniacid']=$_SESSION['uniacid'];
			if($userid){
				$params['userid']=$userid;
			}
			if($kefuid){
				$params['kefuid']=$kefuid;
			}
			$chatid = pdo_getcolumn('core_kefu_chat',$params,'id');
			if(empty($chatid)){
				pdo_insert('core_kefu_chat',$params);
				$chatid = pdo_insertid();
			}
			return $chatid;
		}
}